<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>素材中心</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/hyqcss/public.css">
	<style type="text/css">
		body{
			background: #e9e9e9;
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
		}
		.public_title_container a{
			margin-right: 30px;
			height: 54px;
			line-height: 54px;
			cursor: pointer;
		}
		.public_title_active{
			color: #1E9FFF;
			border-bottom: 1px solid #1E9FFF;
		}
		.public_buttonSearch_container{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20px;
			background: #fff;
		}
		.public_Search_container{
			position: relative;
		}
		.public_Search_container input{
			width: 240px;
			height: 32px;
			border: 1px solid #d9d9d9;
		}
		.public_Search_container i{
			position: absolute;
			bottom: 6px;
			right: 10px;
			cursor: pointer;
		}
		/*公共头部带搜索 end*/
		.public_Search_content{
			display: flex;
		}
		.public_SearchSelect_content input{
			height: 32px;
		}
		.public_SearchSelect_content{
			margin-right: 10px;
		}
		.public_buttonSearch_content{
			display: flex;
		}
		.public_buttonSearch_content a{
			color: #fff;
			background-color: #1E9FFF;
			text-shadow: 0 -1px 0 rgba(0,0,0,.12);
			height: 24px;
			padding: 4px 15px;
			font-size: 14px;
			border-radius: 2px;
			display: flex;
			align-items: center;
		}
		.public_buttonSearch_content span{
			color: rgba(0,0,0,0.65);
			background-color: #fff;
			height: 32px;
			padding: 4px 15px;
			font-size: 14px;
			border-radius: 2px;
			display: flex;
			align-items: center;
			border: 1px solid #d9d9d9;
			margin-left: 10px;
		}
		.public_buttonSearch_daoruhuashu{
			margin-left: 10px;
		}
	</style>
</head>
<body>
	<form class="layui-form">
			<!-- 顶部提示框 开始 -->
		<div class="public_tipSetting_contaienr">
			<div class="public_tipSetting_content">
				<p>功能简介：快捷回复功能对提高工作效率有着很大的帮助，可以在企业微信PC侧边栏（或手机聊天工具栏）将设置好的话术,文件,视频等快速一键发给客户。</p>
			
				<svg t="1599462804099" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8813" width="15" height="15"><path d="M512 102.4a409.6 409.6 0 1 0 409.6 409.6 409.6 409.6 0 0 0-409.6-409.6z m181.248 518.144a51.2 51.2 0 0 1-72.704 72.704L512 584.192l-108.544 109.056a51.2 51.2 0 0 1-72.704-72.704L439.808 512 330.752 403.456a51.2 51.2 0 0 1 72.704-72.704L512 439.808l108.544-109.056a51.2 51.2 0 0 1 72.704 72.704L584.192 512z" fill="" p-id="8814"></path></svg>
			</div>
		</div>
		<!-- 顶部提示框 结束 -->
	<div class="public_container">
		<!-- /*公共头部带搜索*/ -->
		<div class="public_content">
			<div class="public_title_container">
				<a href="/Addons/QyWechat/Admin/Reply/quick_reply.html" class="public_title_active">素材列表</a>
				<a href="/Addons/QyWechat/Admin/Reply/group_manage.html">分组</a>
			</div>
			<div class="public_buttonSearch_container">
				<div class="public_buttonSearch_content">
					<a href="add_quick_reply.html">+ 新建素材</a>
					<a href="javascript:void(0);" class="public_buttonSearch_daoruhuashu">导入话术</a>
					<!--<input type="text" id="toolbarUrl" value="{$toolbarUrl}" style=" position: fixed;  width: 5px;    top: -6px;   height: 6px;" readonly />-->
					<span class="layui-btn layui-btn-primary" onclick="copyToClip('{$toolbarUrl}')">复制工具栏URL</span>
				</div>
				
				<div class="public_Search_content">
					<div class="public_SearchSelect_content">
						<div class="layui-input-inline">
							<select name="type" id="type" lay-filter="type" lay-verify="required">
								<option value="">选择类型</option>
								<option value="1" {if $type==1}selected{/if}>文本</option>
								<option value="2" {if $type==2}selected{/if}>图片</option>
								<option value="3" {if $type==3}selected{/if}>视频</option>
								<option value="4" {if $type==4}selected{/if}>文件</option>
								<option value="5" {if $type==5}selected{/if}>链接</option>
							</select>
						</div>
					</div>
					<div class="public_SearchSelect_content">
						<div class="layui-input-inline">
							<select name="type" id="group" lay-filter="group" lay-verify="required">
								<option value="">选择分组</option>
								{loop $group as $groups}
									<option value="{$groups['keyid']}">{$groups["name"]}</option>
								{/loop}
							</select>
						</div>
					</div>
					<div class="public_Search_container">
						<input type="text" id="name" name="name" value="{$name}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input orders">
						<i class="layui-icon layui-icon-search" onclick="searchName()"></i>
					</div>
				</div>
				
			</div>
		</div>
		</form>
		<!-- /*公共头部带搜索*/ end -->
		<!-- 公共表格部分 -->
		<div class="public_table_container">
			<table class="layui-table" lay-skin="line">
			  <colgroup>
			      <col>
			      <col width="100">
			      <col>
			      <col  width="170">
			      <col  width="170">
			      <col  width="140">
			    </colgroup>
			    <thead>
			      <tr>
			        <th>标题</th>
			        <th>文件类型</th>
			        <th>分组</th>
			        <th>话术内容</th>
			        <th>创建时间</th>
			        <th>排序</th>
			        <th>操作</th>
			      </tr> 
			    </thead>
			    <tbody>
				{loop $res as $r}
				<tr>
			        <td>{$r->name}</td>
			        <td>{$r->typeMsg}</td>
			        <td>{$this->check_name($r->groupid)}</td>
			        <td>{$r->text_content?$r->text_content:'-'}</td>
			        <td>{$r->ctime}</td>
			        <td>
			        	<input type="text" name="order" lay-verify="title" onblur="check('{$r->id}')" id="{$r->id}" autocomplete="off" value="{$r->orders}" class="layui-input" style="border: none;">
			        </td>
			        <td>
			        	<a class="table-public-btn" onclick="location.href='add_quick_reply-{$r->id}.html'">编辑</a>
			        	<a class="table-public-btn" onclick="del_quick_reply({$r->id})">删除</a>
			        </td>
			      </tr>
				{/loop}
			      
			    </tbody>
			</table>
		</div>
		<!-- 公共表格部分 end-->
		<div class="main-container-h pageing-container-h">
		        <div class="pageing-content-h">
		           <span>{$p->totalnum}条/{$p->totalpage}页</span> 
		        </div>
				<ul class="pageing-content-h">
		           {P weidogsadmin}
				</ul>
		    </div>
	</div> 
	
	<script src="/cdn/jquery.js"></script>
	<script src="/layui/layui.js"></script>
	<script src="/js/ajax.js"></script>
	<script type="text/javascript">
		layui.use('form', function(){
		  var form = layui.form;
		  	
		  //监听提交
		  form.on('submit(formDemo)', function(data){
		    layer.msg(JSON.stringify(data.field));
		    return false;
		  });
		  form.render('select');
		  
		  form.on('select(type)', function(data){
			location.href="quick_reply.html?type="+data.value+"&name="+$('#name').val()+"&group="+$('#group').val();
		  });
		  form.on('select(group)', function(data){
			location.href="quick_reply.html?group="+data.value+"&name="+$('#name').val()+"&type="+$('#type').val();
		  });
		});
		function searchName(){
			location.href="quick_reply.html?name="+$('#name').val()+"&type="+$('#type').val();
		}
		function del_quick_reply(id){
			if(confirm('确定删除吗？')){
				myAjaxPost(false, true, 'del_quick_reply.html', { id:id}, function (resp) {
						if (resp.status == 'success') {
							tusi(resp.msg);
							setTimeout(function(){
								location.reload();
							},500);
						}else{
							alert(resp.msg);
						}
					});
			}
		}
	</script>
	<script type="text/javascript">
		function copyToClip(content, message) {
			var aux = document.createElement("input"); 
			aux.setAttribute("value", content); 
			document.body.appendChild(aux); 
			aux.select();
			document.execCommand("copy"); 
			document.body.removeChild(aux);
			if (message == null) {
				layer.msg("复制成功");
			} else{
				layer.msg(message);
			}
		}

		$('.public_buttonSearch_daoruhuashu').on('click',function(){
			layer.open({
			  type: 2,
			  title: '上传话术',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['400px', '350px'],
			  content: 'daoru_huashu.html'
			}); 
		})

		function check(id){
			var order = document.getElementsByName("order");
			for(var i=0;i<order.length;i++){
				if(order[i].id == id){
					order = order[i].value;
				}
			}
			var re = /^\d*$/;
			if (!re.test(order)) { 
				tusi("请输入数字");
				return false; 
			}
			if(order == ""){
				tusi("排序值不可为空");
				return false;
			}
			myAjaxPost(false, true, 'update_order.html', { id:id,order:order}, function (resp) {
				tusi(resp.msg);
			})
		}
	</script>
</body>
</html>